<template>
  <div>
    <div class="box box-show">
      <el-table :data="list" border :row-class-name="tableColor" :height="innerHeight">
        <el-table-column label="咨询时间" prop="advisoryTime" :show-overflow-tooltip="true" />
        <el-table-column label="咨询类型" prop="advisoryType" :show-overflow-tooltip="true" />
        <el-table-column label="分诊类型" prop="remedyType" :show-overflow-tooltip="true" />
        <el-table-column label="咨询分类" prop="consultTypeName" :show-overflow-tooltip="true" />
        <el-table-column label="咨询结果" prop="result" :show-overflow-tooltip="true" />
        <el-table-column label="开单情况" prop="drawSituation" :show-overflow-tooltip="true" />
        <el-table-column label="归档状态" prop="returnToFile" :show-overflow-tooltip="true" />
        <el-table-column label="咨询师" prop="consultantName" :show-overflow-tooltip="true" />
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button
              type="text"
              @click="
                $parent.openAdvisoryRecord(scope.row, scope.row.id, idList)
              "
            >查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        :page-num="params.page"
        :page-size="params.pageSize"
        :on-change="handlePaginationChange"
        :total="total"
      />
    </div>
  </div>
</template>
<script>
import { tableColor } from '@/utils/common.js';
export default {
  props: {
    details: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      list: [],
      tableColor,
      innerHeight: null,
      isDisplay: true,
      params: {
        page: 1,
        pageSize: this.$store.state.commonsettings.maxPageSize,
      },
      total: 0,
      idList: [],
    };
  },
  mounted() {
    if (this.details) {
      this.handlePaginationChange(this.params);
    }
  },
  methods: {
    putItAway(item) {
      item.isDisplay = !item.isDisplay;
    },
    handlePaginationChange(val) {
      this.params = {
        page: val.pageNum,
        pageSize: val.pageSize,
      };
      this.getDataPage();
    },
    async getDataPage() {
      this.loading = true;
      const res = await this.$api["doctor/consulting/listed"]({
        ...this.params,
        query: { customerId: this.details.id },
      });
      this.loading = false;
      if (res.code !== 200) return this.$message.error("查询咨询列表失败！");
      this.list = res.data.result;
      this.list.forEach((item) => {
        this.idList.push(item.id);
      });
      this.total = res.data.total;
    },
  },
};
</script>
<style lang="scss" scoped>
.margin-top {
  margin-top: 20px;
}
.put-itAway {
  cursor: pointer;
}
.margin-left {
  margin-left: 10px;
}
</style>
